import com.codahale.metrics.Gauge;
import org.apache.zookeeper.server.admin.JsonOutputter;

import java.nio.channels.spi.SelectorProvider;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.*;

public class Demo {

    public Demo(){
        System.out.println("demo...");




    }


    public  void  test(){
        System.out.println(Demo.this);
        System.out.println(this);
    }



    public static void main(String[] args) {

        System.out.println(1^1);
        System.out.println(1^3);
        System.out.println(1^7);

        List<String> strList = new ArrayList<String>();

        // 创建了迭代器后,在进行strList的add 操作 抛出ConcurrentModificationException 异常
        for (int i = 0; i < 10; i++)
        {
            strList.add("string" + i);
        }
        Iterator<String> iterator = strList.iterator();
        while (iterator.hasNext())
        {
            System.out.println(iterator.next());
            iterator.remove();
        }
        System.out.println("========");
       strList.forEach(s -> System.out.println(s));



/*

        String s = AccessController.doPrivileged(
                new PrivilegedAction<String>() {
                    public String run() {
                        System.out.println("1");
                        return "1";
                    }
                });

        System.out.println(s);
*/

      /*  Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println(1 / 0);
            }
        });

        thread.setUncaughtExceptionHandler((thread1,e)->{
            System.out.println(thread1.getName()+"111"+e.getMessage());
        });

        thread.start();*/



      /*  Demo demo = new Demo();
        demo.test();*/



       /* int READ = 1 << 0;//1       b 1

        int WRITE = 1 << 1;//2      b 10

        int CREATE = 1 << 2;//4     b 100

        int DELETE = 1 << 3;//8     b 1000

        int ADMIN = 1 << 4;//16     b 10000

        Integer ALL = READ | WRITE | CREATE | DELETE | ADMIN;

        String s = Integer.toBinaryString(ALL);
        System.out.println(s);*/


/*

        ThreadPoolExecutor executor =  new ScheduledThreadPoolExecutor(2, new ThreadFactory() {
            @Override
            public Thread newThread(Runnable r) {

                return  new Thread(r);
            }
        }, new RejectedExecutionHandler() {
            @Override
            public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
                System.out.println("哦no ...");
            }
        });

        Runnable command = new Runnable() {
            @Override
            public void run() {
                System.out.println(Thread.currentThread().getName());
                System.out.println(11);
            }
        };
        System.out.println("执行的任务"+command);
        for (int i = 0; i < 1000; i++) {
            executor.execute(command);
            executor.setKeepAliveTime(1, TimeUnit.MILLISECONDS);

        }
*/




//
//        //只能是左边接口, 即返回一个方法对象
//        InterfaceExample d = Demo::new;
//        //在方法执行后,就是 执行 Demo::new
//        d.create();
//
//        System.out.println(d);

    }



    public static void aaa(String content){
        System.out.println(content);
    }
}


interface InterfaceExample{
    Demo create();


}
